package com.yjq.programmer.controller.app;

import com.yjq.programmer.dto.MusicDTO;
import com.yjq.programmer.dto.MusicMenuDTO;
import com.yjq.programmer.dto.ResponseDTO;
import com.yjq.programmer.service.IMusicService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 杨杨吖
 * @QQ 823208782
 * @WX yjqi12345678
 * @create 2022-11-19 8:58
 */
@RestController("AppMusicController")
@RequestMapping("/app/music")
public class MusicController {

    @Resource
    private IMusicService musicService;

    /**
     * 小程序根据专辑id获取音乐数据
     * @param musicDTO
     * @return
     */
    @PostMapping("/getByAlbumId")
    public ResponseDTO<List<MusicDTO>> appGetMusicListByAlbumId(@RequestBody MusicDTO musicDTO) {
        return musicService.getMusicListByAlbumId(musicDTO);
    }

    /**
     * 小程序根据歌单id获取音乐数据
     * @param musicMenuDTO
     * @return
     */
    @PostMapping("/getByMusicMenuId")
    public ResponseDTO<List<MusicDTO>> appGetMusicListByMusicMenuId(@RequestBody MusicMenuDTO musicMenuDTO) {
        return musicService.getMusicListByMusicMenuId(musicMenuDTO);
    }

    /**
     * 小程序根据歌手id获取音乐数据
     * @param musicDTO
     * @return
     */
    @PostMapping("/getBySingerId")
    public ResponseDTO<List<MusicDTO>> appGetMusicListBySingerId(@RequestBody MusicDTO musicDTO) {
        return musicService.getMusicListBySingerId(musicDTO);
    }

    /**
     * 小程序搜索音乐
     * @param musicDTO
     * @return
     */
    @PostMapping("/search")
    public ResponseDTO<List<MusicDTO>> appSearchMusic(@RequestBody MusicDTO musicDTO) {
        return musicService.searchMusic(musicDTO);
    }

    /**
     * 小程序根据id获取音乐数据
     * @param musicDTO
     * @return
     */
    @PostMapping("/getMusicById")
    public ResponseDTO<MusicDTO> appGetMusicById(@RequestBody MusicDTO musicDTO) {
        return musicService.getMusicById(musicDTO);
    }


    /**
     * 小程序音乐播放数增加
     * @param musicDTO
     * @return
     */
    @PostMapping("/addListen")
    public ResponseDTO<Boolean> appAddMusicListen(@RequestBody MusicDTO musicDTO) {
        return musicService.addMusicListen(musicDTO);
    }

    /**
     * 小程序获取前五个收藏最多的音乐
     * @return
     */
    @PostMapping("/topFiveCollect")
    public ResponseDTO<List<MusicDTO>> appGetTopFiveCollectMusic() {
        return musicService.getTopFiveCollectMusic();
    }

    /**
     * 小程序获取前五个最新上架的音乐
     * @return
     */
    @PostMapping("/topFiveNew")
    public ResponseDTO<List<MusicDTO>> appGetTopFiveNewMusic() {
        return musicService.getTopFiveNewMusic();
    }


    /**
     * 小程序获取前五个播放量最高的音乐
     * @return
     */
    @PostMapping("/topFiveListen")
    public ResponseDTO<List<MusicDTO>> appGetTopFiveListenMusic() {
        return musicService.getTopFiveListenMusic();
    }
}
